<template>
  <div>
    <el-table
      stripe
      border
      :cell-style="{ 'text-align': 'center' }"
      :header-cell-style="{ 'text-align': 'center' }"
      size="mini"
      :data="
        tableData.filter(
          (data) =>
            !search ||
            data.activity_name.toLowerCase().includes(search.toLowerCase())
        )
      "
      style="width: 100%"
      height="95vh"
    >
      <el-table-column label="ID" width="100" prop="essay_id">
      </el-table-column>
      <el-table-column label="发表用户" width="80" prop="user_id">
      </el-table-column>
      <el-table-column label="动态类型" width="80">
        <template slot-scope="scope">
          <el-tag type="primary">
            {{
              scope.row.type === 1
                ? "图文"
                : scope.row.type === 6
                  ? "话题"
                  : scope.row.type === 7
                    ? "提问"
                    : scope.row.type === 5
                      ? "投票"
                      : "未知"
            }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="发布时间" width="200" prop="create_time">
      </el-table-column>
      <el-table-column label="发布地点" width="200" prop="user_location">
      </el-table-column>
      <el-table-column label="发布内容" width="300" prop="user_essay">
      </el-table-column>
      <el-table-column label="点赞数" width="100" prop="likeNum">
      </el-table-column>
      <el-table-column label="评论数" width="100" prop="discussNum">
      </el-table-column>
      <el-table-column label="图片" width="200" prop="essay_img">
        <template slot-scope="scope">
          <!-- scope.row.essay_img -->
          <div v-for="(item,index) in scope.row.essay_img" :key="index">
            <img :src="item" width="100" alt="">
            <!-- {{item}} -->
          </div>
        </template>
      </el-table-column>
      <el-table-column width="120" align="right" fixed="right">
        <template slot="header">
          审核
          <el-input v-model="search" size="mini" placeholder="输入关键字搜索" />
        </template>
        <template slot-scope="scope">
          <!-- <div>
            <el-button
              size="mini"
              @click="handleAllow(scope.row.id, scope.$index, tableData)"
            >审核通过</el-button >
          </div> -->
          <div class="mt-1">
            <el-button
              size="mini"
              type="danger"
              @click="handleRefuse(scope.row.id, scope.$index, tableData)"
            >屏蔽</el-button >
          </div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      search: "",
      getinfoListStore: this.newStore(),

      page: 0,
      tableData: [],
    };
  },
  created() {
    this.getinfoList();
  },
  methods: {
    handleRefuse(id, index, rows) {
      this.spost(this.getinfoListStore, "/Admin/getinfoList", {
        id,
        num: 2,
      }).then(() => {
        this.$message.success("操作成功！");
        rows[index].check = 2;
      });
    },
    handleAllow(id, index, rows) {
      this.spost(this.getActivityStore, "/Admin/ActivityEditor", {
        id,
        num: 1,
      }).then(() => {
        this.$message.success("操作成功！");
        rows[index].check = 1;
      });
    },
    getinfoList() {
      this.spost(this.getinfoListStore, "/Admin/getinfoList", {
        num: this.num,
        page: this.page,
      }).then((res) => {
        this.tableData = res.d.MoodList;
      });
    },
  },
};
</script>

<style scoped lang="scss">
</style>
